package br.com.etecmatao.admin.converter;

import br.com.etecmatao.business.impl.BusinessLocatorImpl;
import br.com.etecmatao.model.Albuns;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

@FacesConverter(forClass=Albuns.class,value="albumConverter")
public class AlbumConverter implements Converter{

	public Object getAsObject(FacesContext context, UIComponent component, String valor) {
		if(valor == null || valor.equals("null") || valor.length()==0)return null;
		return new BusinessLocatorImpl().getAlbunsBusiness().findById(Integer.valueOf(valor));
	}

	public String getAsString(FacesContext context, UIComponent component, Object object) {
		if(object == null)return null;
		return ((Albuns)object).getIdAlbuns().toString();
	}

}